package pay.commont;

public enum GameType {
    PERSONAL(1, "个人赛"),
    TEAM(2, "团队赛"),
    PARENT_CHILD(3, "亲子赛");

    private final int code;
    private final String desc;

    GameType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据 code 获取对应的枚举值
     */
    public static GameType getByCode(int code) {
        for (GameType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    /**
     * 根据 desc 获取对应的枚举值
     */
    public static GameType getByDesc(String desc) {
        for (GameType type : values()) {
            if (type.desc.equals(desc)) {
                return type;
            }
        }
        return null;
    }
}